#include <iostream>

#include "Databank.hpp"
#include "TurnSchedule.hpp"

#include "Actor.hpp"

Actor::Actor(std::string name, unsigned int race) : 
	GameObject(name, Databank::Race[race].Shape, Vector2d(0, 0), Databank::Race[race].Size, false), Alive(true), Race(race)
{
	TurnSchedule::scheduleTurn(this, 1);
}

Actor::~Actor()
{
}

bool Actor::isAlive()
{
	return Alive;
}

bool Actor::takeTurn()
{
	if (Alive)
	{
		unsigned int delay = 10;
		TurnSchedule::scheduleTurn(this, delay);
	}
	else
	{
		// do dead things
	}

	return true;
}

unsigned int Actor::getSight()
{
	return Databank::Race[Race].Sight;
}

unsigned int Actor::move(Vector2d offset)
{
	Tile* tile = Area->getTile(Position+offset);
	if (tile)
	{
		Position += offset;
		return Databank::Race[Race].Speed;
	}

	//Tile* tile = Area->getTile(Position+offset);
	//if (tile && tile->isPassable())
	//{
	//	Position += offset;
	//	return Databank::Race[Race].Speed;
	//}

	return 0;
}

void Actor::kill()
{
	Alive = false;
}

void Actor::setZone(Zone* area)
{
	Area = area;
}
